new Vue({
    el: '#app',
    data() {
        return {
            fileList: [],
            limit: 1,//上传最大文件数
            form: {
                Components_SerialNumber: '',
                Components_Name:'',
                Components_Sign:'',
                Enterprise_Info_SerialNumber:$.cookie('token'),
            },
            rules: {
                Components_Name: [{ required: true, message: '请输入组件名称', trigger: 'blur' }],
                Components_Sign: [{ required: true, message: '请输入组件标识', trigger: 'blur' }],
            },
            loading: false,
        }
    },
    mounted() {
        
    },
    methods: {
        submitForm(formName) {
            let that = this
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    that.loading = true
                    $.ajax({
                        url: BASE_URL + '/getAddAction?grant_type=tourist',
                        type: 'POST',
                        data: {
                            Data: JSON.stringify({
                                base_components_info: [that.form]
                            }),
                            Operation_Name: '添加组件'
                        },
                        success: function (res) {
                            if (res.Status === 'success') {
                                that.$message.success("提交成功")
                                window.history.go(-1)
                            } else {
                                that.$message.error("提交失败，请稍后再试")
                            }
                        },
                        error: function () {
                            that.$message.error("操作失败，请稍后再试")
                        },
                        complete: function (XMLHttpRequest) {
                            that.loading = false
                            if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
                                window.parent.document.location.href = absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
                            }
                        }
                    })
                } else {
                    return false;
                }
            });
        },
        handleExceed(){

        },
        handleChange(){

        },
        resetForm(formName) {
            this.$refs[formName].resetFields();
        },
    }
})